import 'package:spring_fairy/model/mood_track_point.dart';

class MoodTrack {
  int? id;
  String? title;
  DateTime? trackDate;
  DateTime? createdAt;

  List<MoodTrackPoint>? points;

  MoodTrack({
    this.id,
    this.title,
    this.trackDate,
    this.createdAt,
  });

  factory MoodTrack.fromJson(Map<String, dynamic> json) => MoodTrack(
    id: json['id'],
    title: json['title'],
    trackDate: json['trackDate'] != null ? DateTime.parse(json['trackDate']) : null,
    createdAt: json['createdAt'] != null ? DateTime.parse(json['createdAt']) : null,
  );

  Map<String, dynamic> toJson() => {
    'id': id,
    'title': title,
    'trackDate': trackDate?.toIso8601String(),
    'createdAt': createdAt?.toIso8601String(),
  };

  @override
  String toString() {
    return 'MoodTrack{id: $id, title: $title, trackDate: $trackDate, createdAt: $createdAt, points: $points}';
  }

  @override
  bool operator ==(Object other) {
    if(other is! MoodTrack) {
      return false;
    }
    return other.id == id;
  }

  @override
  int get hashCode => id!;

}
